<template>
  <a-modal
    title="发货明细"
    :width="1200"
    :visible="visible"
    :confirmLoading="confirmLoading"
    :footer="null"
    @ok="handleSubmit"
    @cancel="handleCancel">

    <a-card :bordered="false">

      <s-table
        ref="table"
        size="default"
        :columns="columns"
        :data="loadData"
        :alert="true"
        :rowKey="(record) => record.code"
        :rowSelection="null"
        :showPagination="false"
      >
      </s-table>

    </a-card>
  </a-modal>
</template>

<script>
import {STable} from '@/components'
import {page} from '@/api/modular/main/emsordermaterial/emsOrderMaterialManage'

export default {
  components: {
    STable,
  },

  data() {
    return {
      advanced: false, // 高级搜索 展开/关闭
      queryParam: {},  // 查询参数
      columns: [
        {
          title: '序号', width:'80px',
          dataIndex: 'index',
          customRender: (text, record, index) => `${index + 1}`
        },
        {
          title: '发货单号',
          dataIndex: 'orderNumber',
        },
        {
          title: '发货时间',
          dataIndex: 'createTime',
        },
        {
          title: '发货数量',
          dataIndex: 'number',
        },
        {
          title: '入库数量',
          dataIndex: 'inStoreNumber',
        },
        {
          title: '异常数量',
          dataIndex: 'abnormalNumber',
        },
      ],
      // 加载数据方法 必须为 Promise 对象
      loadData: parameter => {
        return page(Object.assign(parameter, this.queryParam)).then((res) => {
          res.data.rows.forEach(value => {
            value.thisCompleteNumber = 0
          })
          return res.data
        })
      },
      selectedRowKeys: [],
      selectedRows: [],
      defaultExpandedKeys: [],
      visible: false,
      confirmLoading: false,
      record: null,
      viewState: '',
      extra: {},
    }
  },
  methods: {
    show(record) {
      this.visible = true
      this.record = record
      this.queryParam.sourceOrderMaterialId = this.record.orderMaterialId
      this.queryParam.orderType = this.$businessEnum.ORDER_TYPE_ENUM.deliverOrder.id
      setTimeout(() => {
        this.handleOk()
      }, 100)
    },
    handleOk() {
      this.$refs.table.refresh()
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    },
    handleSubmit() {
    },
    handleCancel() {
      this.visible = false
    },
  }
}
</script>

<style lang="less">
.table-operator {
  margin-bottom: 18px;
}

button {
  margin-right: 8px;
}
</style>
